package PTA.javaA;

import java.util.List;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;


public class ex26 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Set<String> ith = new TreeSet<>();
    while(true){
        String line = sc.next();
        if(line.equals("!!!!!")){
            break;
        }else{
            ith.add(line);
        }
    }
        System.out.println(ith.size());

   if(ith.size()<10){

  for(String i:ith){
      System.out.println(i);
  }

   }else {
       int count=0;
       for(String i:ith){
           if(count++>9){
               break;
           }
           System.out.println(i);
       }
   }
   sc.close();

























    }
}
